#!/usr/bin/perl -w

use Test::More tests => 2;

# =============================================================
# Cargamos el modulo
# ==============================================================
use_ok('Bench::Test');

my $bt = Bench::Test->new(
   config_file => \*DATA,
);

ok($bt->make_tests, 'Using "Bench::Test::make_test"');

__DATA__

# =============================================================
# A continuacion un ejemplo de fichero de configuracion
# =============================================================

@TESTS = (
   pi100000  =>  '1000000',
   pi200000  =>  '2000000',
   pi500000  =>  '5000000',
   pi1000000 => '10000000',
);

@TABLE = (
   TIME  => { REGEXP => 'Time:\s+(.*?)\n' },
   NOI   => { REGEXP => 'Number of intervals: (.*?)\n' },
   PI    => { REGEXP => 'Calculated Pi: (.*?)\n' }
);

%EXPERIMENTS = (
   LOCAL => Bench::Test::Local->new(
               WORKDIR => 'examples/pi',
               EXECUTABLE => './pi',
            ),
);

@VISUAL = qw(TEST NAME NOI TIME PI);
@SELECTED = qw(LOCAL);
@UNIQUE = qw(PI NOI TIME);

@OUTPUTFORMAT = ( 'text' => '' );

sub Bench::Test::Entry::is_OK {
   my $self = shift;

   my @fields  = $self->get_fields;
   my @uniques = $self->get_uniques;

   for my $exp_name ($self->get_exp_names) {
      my $calculated_pi = $self->get_field_value('PI', $exp_name);
      return 0 unless ($calculated_pi =~ /^3.141592/)
   }
   return 1;
}

